﻿ALLYS = "ALLYS"
ENEMYS = ENEMYS

class Nations():
	def __init__(this):
		this.nation = None
	
	def selfTest(this):
		#смысл самотеста таков: надо проверить расписки на предмет:
		#1. того, что все используемые национальности присутствуют в списке
		for nation in nations:
			for ally in nations[nation][ALLYS]:
				if not nations.has_key(ally):
					print "Nations has no", ally, "- ally of", nation
					return False
			for enemy in nations[nation][ENEMYS]:
				if not nations.has_key(enemy):
					print "Nations has no", enemy, "- enemy of", nation
					return False
		
		#2. что если сторона А есть во врагах стороны Б, то и обратное тоже верно
		for nation in nations:
			for enemy in nations[nation][ENEMYS]:
				if nations[enemy][ENEMYS].count(nation) == 0:
					print "Nation", enemy, "enemy of", nation, "but", nation, "not enemy of", enemy
					return False
		
		return True #todo
	
	def setNation(this, nation):
		if not nations.has_key(nation):
			raise "No", nation, "nation"
		this.nation = nation
	
	def hasEnemy(this, enemy):
		return (nations[this.nation][ENEMYS].count(enemy) > 0) 

	def hasAlly(this, ally):
		return (nations[this.nation][ALLYS].count(ally) > 0) 
		
#nation, her ally, her enemy
nations = {
	"ROME": 
	{ALLYS: ["GALLS", "MAKEDONIC"],
	ENEMYS: ["KARFAGEN", "GALLS", "MAKEDONIC"]},
	
	"GALLS": 
	{ALLYS: [],
	ENEMYS: ["ROME"]},

	"KARFAGEN": 
	{ALLYS: ["GALLS", "MAKEDONIC"],
	ENEMYS: ["ROME"]},

	"MAKEDONIC": 
	{ALLYS: [],
	ENEMYS: ["ROME"]},	
}

if __name__ == "__main__":
	n = Nations()
	print n.selfTest()